package com.yswl.pri.common.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by kangpAdministrator on 2018/8/1 0001.
 * Emial kangpeng@yunhetong.net
 */

public class MDateUtils {

    /**
     * 比较时间大小
     *
     * @param str1：要比较的时间
     * @param str2：要比较的时间
     * @return
     */
    public static boolean isDateOneBigger(String str1, String str2) {
        boolean isBigger = false;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date dt1 = null;
        Date dt2 = null;
        try {
            dt1 = sdf.parse(str1);
            dt2 = sdf.parse(str2);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        if (dt1.getTime() > dt2.getTime()) {
            isBigger = true;
        } else if (dt1.getTime() < dt2.getTime()) {
            isBigger = false;
        }
        return isBigger;
    }

    public static boolean isOverDue(String oldTime, long currTime, long spaceTime) {
        boolean isBigger = false;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date dt1 = null;
        try {
            dt1 = sdf.parse(oldTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        if (dt1 != null) {
            if ((currTime - dt1.getTime()) / (24 * 60 * 60 * 1000) > spaceTime) {
                isBigger = true;
            }
        }

        return isBigger;
    }
}
